import decimal
import os
import re
import copyfile
with open('verison.cfg','r') as a:
    original = a.read()
    copyfile.copyFile('JRFrpGUI.py', f'backup/JRFrpGUI_Backup_{original}')
with open('verison.cfg','w') as b:
    version = decimal.Decimal(original) + decimal.Decimal('0.1')
    version1 = str(version)
    with open('JRFrpGUI.py', 'r',encoding='utf-8') as c:
        d = c.read()
    with open('JRFrpGUI.py', 'w',encoding='utf-8') as e:
        f = re.sub(f'version = "{original}"',f'version = "{version1}"',d)
        e.write(f)
    b.write(str(version))
    os.system('pyinstaller -i ico.ico -w -F JRFrpGUI.py')
    os.system(f'rename dist\JRFrpGUI.exe JRFrpGUI_{version}.exe')
    os.remove('JRFrpGUI.spec')
    os.remove(f'dist/JRFrpGUI_{original}.exe')